<%--
  Created by IntelliJ IDEA.
  User: a
  Date: 2024/8/16
  Time: 8:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改图书信息</title>
    <%
        String base = request.getContextPath()+"/";
        String url = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+base;
    %>
    <base href="<%=url%>">
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //1.窗体加载后，发送异步请求：
            var bid=$("[name='hitxt']").val();
            $.get("book/queryByid",{"bid":bid},function (book) {
                JSON.stringify(book);
                $("[name='bname']").val(book.bookName);
                $("[name='aname']").val(book.bookAuthor);
                $("[name='cname']").val(book.bookPublish);
                $("[name='page']").val(book.bookPage);
                $("[name='price']").val(book.bookPrice);
                $("[name='date']").val(book.createDate);
            });

            //2.窗体加载后，提交按钮 单击事件，发送异步请求：
            $("[type='button']").click(function () {
                var bname=$("[name='bname']").val();
                var aname=$("[name='aname']").val();
                var cname=$("[name='cname']").val();
                var page=$("[name='page']").val();
                var price=$("[name='price']").val();
                var date=$("[name='date']").val();
                var bid=$("[name='hitxt']").val();

                $.get("book/update",
                    {
                        "bname":bname,
                        "aname":aname,
                        "cname":cname,
                        "page":page,
                        "price":price,
                        "date":date,
                        "bid":bid
                    }
                    ,function (mess) {
                        JSON.stringify(mess);
                        if(mess){
                            alert("修改成功");
                        }else{
                            alert("修改失败");
                        }
                });
            });
        });
    </script>
</head>
<body>

<a href="index.jsp">返回</a>
<h1>修改图书</h1>
书名：<input type="text" name="bname"/><br/>
作者：<input type="text" name="aname"/><br/>
出版社：<input type="text" name="cname"/><br/>
页数：<input type="text" name="page"/><br/>
价格：<input type="text" name="price"/><br/>
创建时间：<input type="date" name="date"/><br/>
<input type="button" value="提交"/><br/>

<input type="hidden" name="hitxt" value="<%=request.getParameter("bid")%>"/>

</body>
</html>
